/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * OptionPanel.java
 *
 * Created on 19-Mar-2011, 5:58:58 PM
 */

package com.inse6260.atms.view;

import com.inse6260.atms.controller.ATMSController;

/**
 * @author dimitri.tiago
 */
public class ATMSMainMenu extends javax.swing.JPanel
{
    // fields
    private ATMSController atmsController;

    private String currentSelection;

    /** Creates new form OptionPanel */
    public ATMSMainMenu(ATMSController atmsController)
    {
        initComponents();

        // field initialization
        this.atmsController = atmsController;
        currentSelection = "";

        // TODO: ake visible when functionality imlemented
        jButton4.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        optionsHeaderLabel = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();

        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        optionsHeaderLabel.setFont(new java.awt.Font("Tahoma", 1, 18));
        optionsHeaderLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        optionsHeaderLabel.setText("Please select a transaction.");
        optionsHeaderLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jButton1.setText("> Withdrawal");
        jButton1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ATMSMainMenu.this.actionPerformed(evt);
            }
        });

        jButton2.setText("> Deposit");
        jButton2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ATMSMainMenu.this.actionPerformed(evt);
            }
        });

        jButton3.setText("> Transfer");
        jButton3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ATMSMainMenu.this.actionPerformed(evt);
            }
        });

        jButton4.setText("> Payment");
        jButton4.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        jButton5.setText("> Account Information");
        jButton5.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ATMSMainMenu.this.actionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(optionsHeaderLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 432, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(148, 148, 148)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)
                    .addComponent(jButton5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)
                    .addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)
                    .addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)
                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE))
                .addGap(161, 161, 161))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addComponent(optionsHeaderLabel)
                .addGap(28, 28, 28)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton4)
                .addContainerGap(43, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void actionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_actionPerformed

        currentSelection = evt.getActionCommand();

        // if withdrawal transaction
        if (currentSelection.equalsIgnoreCase("> Withdrawal"))
        {
            atmsController.setCurrTransaction("withdrawal");
            atmsController.showAccSelPanel();
        }

        // if deposit transaction
        if (currentSelection.equalsIgnoreCase("> Deposit"))
        {
            atmsController.setCurrTransaction("deposit");
            atmsController.showAmtInputPanel();
        }

        // if deposit transaction
        if (currentSelection.equalsIgnoreCase("> Transfer"))
        {
            atmsController.setCurrTransaction("transfer");
            atmsController.showAmtInputPanel();
        }

        // if account information transaction
        if (currentSelection.equalsIgnoreCase("> Account Information"))
        {
            atmsController.setCurrTransaction("information");
            atmsController.showAccInfoMenuPanel();
        }
    }//GEN-LAST:event_actionPerformed

    public String getSelection()
    {
        return currentSelection;
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JLabel optionsHeaderLabel;
    // End of variables declaration//GEN-END:variables

}
